package com.ybt.ruleengine.expander.router.util;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.ruleengine.frame.callback.IRuleEngineCallback;

public class RuleEngineCallbackPool {
    private Map<String, IRuleEngineCallback> poolMap;
    private volatile static RuleEngineCallbackPool pool;

    private RuleEngineCallbackPool() {
        poolMap = new ConcurrentHashMap<String, IRuleEngineCallback>();
    }

    public static RuleEngineCallbackPool getInstance() {
        if (pool == null) {
            synchronized (RuleEngineCallbackPool.class) {
                if (pool == null) {
                    pool = new RuleEngineCallbackPool();
                }
            }
        }
        return pool;
    }

    public IRuleEngineCallback removeRuleEngineCallback(String excuteId) {
        return poolMap.remove(excuteId);
    }

    public void putRuleEngineCallback(String excuteId, IRuleEngineCallback callback) {
        poolMap.put(excuteId, callback);
    }

}
